Bounds check lat/lon in waypt.c to try to help catch bogus data
authorrobertl <robertl>
Fri, 1 Sep 2006 17:15:41 +0000 (17:15 +0000)
committerrobertl <robertl>
Fri, 1 Sep 2006 17:15:41 +0000 (17:15 +0000)
that makes it through the various readers.

waypt.c

diff --git a/waypt.c b/waypt.c
index 0d2cd1c3a1edf7469cca24206b80c938028faf67..57985ed228da28b07e4443e4a490e5ebd736edce 100644 (file)
--- a/waypt.c
+++ b/waypt.c
@@ -87,6 +87,11 @@ waypt_add(waypoint *wpt)
        ENQUEUE_TAIL(&waypt_head, &wpt->Q);
        waypt_ct++;
 
+       if ((wpt->latitude < -90) || (wpt->latitude > 90.0))
+               fatal ("Invalid latitude %f in waypoint.\n", wpt->latitude);
+       if ((wpt->longitude < -180) || (wpt->longitude > 180.0))
+               fatal ("Invalid longitude %f in waypoint.\n", wpt->latitude);
+
        /*
         * Some input may not have one or more of these types so we
         * try to be sure that we have these fields even if just by